﻿@using Lari.Configuration
@using Lari.Web.Utility
@model Lari.Services.ViewModel.EmployeeModel
<div id="pagetitle">
    <h1>@ScreenName.Users.ViewEmployee</h1>
</div>
<div class="spacer">
</div>
@{
    int age = 0;
    string ageDisplay = "";

    if (!Model.IsDOBCulculated)
    {
        if (Model.DOB != null)
        {
            age = (DateTime.Now - Model.DOB.Value).Days / 365;
        }
    }
    if (age > 0)
    {
        ageDisplay = string.Format("({0} Yrs)", age);
    }
}
<div id="pagecontent">
    <table style="border-collapse: collapse; width: 100%; padding: 10; border-spacing: 10px">
        <tr>
            <td width="25%">
                <div class="tab">
                    General Details</div>
                <div class="tabContent">
                    <table>
                        <tr>
                            <td>
                                Employee #
                            </td>
                            <td>
                                <strong>@Model.ID</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Name
                            </td>
                            <td>
                                <strong>@this.NvlFullName(this.LookupInfo(LookupEnum.Title, Model.Title), Model.FirstName, Model.Middlename, Model.LastName)</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Consultant
                            </td>
                            <td>
                                <strong>@this.Nvl(Model.IsConsultant)</strong>
                            </td>
                        </tr>
                        <tr>
                            @if (Model.IsDOBCulculated)
                            {
                                <td>
                                    Age(Yrs)
                                </td>
                                <td>
                                    <strong>@this.Nvl(Model.Age)</strong>
                                </td>
                            }
                            else
                            {
                                <td>
                                    DoB
                                </td>
                                <td>
                                    <strong>@this.Nvl(Model.DOB) @ageDisplay </strong>
                                </td>
                            }
                        </tr>
                        <tr>
                            <td>
                                Gender
                            </td>
                            <td>
                                <strong>@this.LookupInfo(LookupEnum.Gender, Model.GenderCode)</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Marital Status
                            </td>
                            <td>
                                <strong>@this.LookupInfo(LookupEnum.MaritalStatus, Model.MaritalStatusCode)</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Religion
                            </td>
                            <td>
                                <strong>@this.LookupInfo(LookupEnum.Religion, Model.ReligionCode)</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Nationality
                            </td>
                            <td>
                                <strong>@this.LookupInfo(LookupEnum.Country, Model.NationalityCode)</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Bloodgroup
                            </td>
                            <td>
                                <strong>@this.LookupInfo(LookupEnum.Bloodgroup, Model.BloodGpId)</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Department
                            </td>
                            <td>
                                <strong>@this.LookupInfo(LookupEnum.Department, Model.DepartmentId)</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Designation
                            </td>
                            <td>
                                <strong>@this.LookupInfo(LookupEnum.Designation, Model.DesignationId)</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Employee type
                            </td>
                            <td>
                                <strong>@this.LookupInfo(LookupEnum.EmploypeeType, Model.EmployeeType)</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Mobile #
                            </td>
                            <td>
                                <strong>@this.Nvl(Model.Mobile)</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Email
                            </td>
                            <td>
                                <strong>@this.Nvl(Model.Email)</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Active
                            </td>
                            <td>
                                <strong>@this.Nvl(Model.Active)</strong>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="spacer">
                </div>
            </td>
            <td width="40%">
                <div class="tab">
                    Home Address</div>
                <div class="tabContent">
                    <div>
                        <strong>Address</strong></div>
                    <div>@this.Nvl(Model.HomeAddress)</div>
                    <div>@this.Nvl(Model.HomeCity)</div>
                    @if (string.IsNullOrWhiteSpace(Model.HomeStateCode))
                    {
                        <div>@this.Nvl(Model.HomeStateOther) @this.LookupInfo(LookupEnum.Country, Model.HomeCountryCode)</div> 
                   
                    }
                    else
                    {
                        <div>@this.LookupInfo(LookupEnum.State, Model.HomeStateCode) @this.LookupInfo(LookupEnum.Country, Model.HomeCountryCode)</div>
                    }
                    <div>
                        <strong>Pin</strong>: @this.Nvl(Model.HomePinCode)</div>
                    <div>
                        <strong>Ph#</strong>: @this.Nvl(Model.HomePhone)</div>
                </div>
                <div class="spacer">
                </div>
                <div class="tab">
                    Work Address</div>
                <div class="tabContent">
                    <div>
                        <strong>Address</strong></div>
                    <div>@this.Nvl(Model.WorkAddress)</div>
                    <div>@this.Nvl(Model.WorkCity)</div>
                    @if (string.IsNullOrWhiteSpace(Model.WorkStateCode))
                    {
                        <div>@this.Nvl(Model.WorkStateOther) @this.LookupInfo(LookupEnum.Country, Model.WorkCountryCode)</div> 
                   
                    }
                    else
                    {
                        <div>@this.LookupInfo(LookupEnum.State, Model.WorkStateCode) @this.LookupInfo(LookupEnum.Country, Model.WorkCountryCode)</div>
                    }
                    <div>
                        <strong>Pin</strong>: @this.Nvl(Model.WorkPinCode)</div>
                    <div>
                        <strong>Ph#</strong>: @this.Nvl(Model.WorkPhone)</div>
                </div>
                <div class="spacer">
                </div>
                <div class="tab">
                    Login deatils</div>
                <div class="tabContent">
                    <table>
                        @if (Model.User != null)
                        {
                            <tr>
                                <td>
                                    Login Id
                                </td>
                                <td>
                                    &nbsp;&nbsp;
                                </td>
                                <td>
                                    <strong>@this.Nvl(Model.User.UserId)</strong>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Role
                                </td>
                                <td>
                                    &nbsp;&nbsp;
                                </td>
                                <td>
                                    <strong>@this.LookupInfo(LookupEnum.Role, Model.User.RoleId)</strong>
                                </td>
                            </tr>
                   
                        }
                        else
                        {
                            <tr>
                                <td>
                                    <div class="error">
                                        <strong>@MessageCode.Generic.NotDefined</strong></div>
                                </td>
                            </tr>
                     
                        }
                    </table>
                </div>
                <div class="spacer">
                </div>
            </td>
            <td width="20%">
                <div class="tab">
                    Action & Navigation</div>
                <div class="tabContent">
                    <div>@Html.ActionLink(GuiActionName.Edit, ActionConst.Users.EditEmployee, new { id = Model.ID })</div>
                    <div class="spacer">
                    </div>
                    @if (Model.IsConsultant)
                    {
                        <div>@Html.ActionLink(ScreenName.Users.ManageConsultantSpecialization, ActionConst.Users.ConsultantSpecialization, new { id = Model.ID })</div>
                        <div class="spacer">
                        </div>    
                    }
                    <div>@Html.ActionLink("Qualifications Details", ActionConst.Users.EmployeeQualification, ControllerConst.Users, new { id = Model.ID })</div>
                    <div class="spacer">
                    </div>
                    <div>@Html.ActionLink("License Details", ActionConst.Users.EmployeeLicense, ControllerConst.Users, new { id = Model.ID })</div>
                    <div class="spacer">
                    </div>
                    @if (Model.User == null)
                    {
                        <div>@Html.ActionLink("Map system user for login", ActionConst.Users.CreateLoginUser, new { id = Model.ID })</div>
                   
                    }
                    else
                    {
                        <div>@Html.ActionLink("Reset password", ActionConst.Users.ResetPassword, new { id = Model.ID })</div>
                        <div class="spacer">
                        </div>
                        <div>@Html.ActionLink("Change Role", ActionConst.Users.ChangeRole, new { id = Model.ID })</div>
                    }
                    <div class="doubleSpacer">
                    </div>
                    @if (Model.Active)
                    {
                        <div>@Html.ActionLink("De-Activate", ActionConst.Users.MakeInActive, new { id = Model.ID })</div>
                        
                    }
                    else
                    {
                        <div>@Html.ActionLink("Activate", ActionConst.Users.MakeActive, new { id = Model.ID })</div>
                    }
                </div>
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">

    $(document).ready(function () {
        $("#btnActivate").button();
        $("#btnDeActivate").button();

    });
</script>
